$(function () {

   layui.use(['carousel','element'], function(){
        var carousel = layui.carousel;
        var element = layui.element;
       //轮播
        carousel.render({
            elem: '#test1'
            ,width: '100%' //设置容器宽度
            ,arrow: 'always' //始终显示箭头
        });

       //导航
       element.on('nav', function(elem){
           console.log(elem.attr('navindex')); //得到当前点击的DOM对象
       });
   });
})